package com.es.www.transaction.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.es.www.transaction.Dao.FinanceDao;
import com.es.www.transaction.aspect.TransactionControl;

/**
 * @Created by michangtao
 * @Date 2022/2/9 15:40
 * @Description
 */
@Service
public class FinanceService {


    @Autowired
    private FinanceDao financeDao;


    @TransactionControl
    public void transfer(Long sourceId, Long targetId, Integer num){
        financeDao.substractMoney(sourceId,num);
        System.out.println("用户：" + sourceId + "扣除了：" + num);
        int i = 10/0;
        financeDao.addMoney(targetId,num);
        System.out.println("用户：" + sourceId + "入账了：" + num);
    }

}
